/**
 * 
 */
package com.icygen.eclipsetools.ui.wizards;

import java.util.ArrayList;

import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.tigris.subversion.svnclientadapter.SVNClientException;

import com.icygen.core.svn.Repository;
import com.icygen.eclipsetools.project.IcygenThemesSupport;

/**
 * @author vanko
 *
 */
public class ProjectThemesPage extends WizardPage
{
	private Composite container;
	
	private ArrayList<Button> checkboxThemes;
	
	public ProjectThemesPage() 
	{
	    super("Project Themes");
	    setTitle("Project Themes");
	    setDescription("VS Tools Create Project Wizard Themes Page.");
	}

	/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
	 */
	@Override
	public void createControl(Composite parent)
	{
		System.out.println("BEGIN createControl");
		
		
		ArrayList<String> themes = new ArrayList<String>();
		
		container = new Composite(parent, SWT.NONE);
	    GridLayout layout = new GridLayout();
	    container.setLayout(layout);
	    layout.numColumns = 2;
	    /*
	    try {
		    Repository themesRepository = new Repository(Repository.IcygenThemesUrl, "guest", "");
		    themes = themesRepository.getList("");
	    } catch(SVNClientException e) {
			System.out.println(e.getMessage());
		}
	    */
	    checkboxThemes = new ArrayList<Button>();
	    for(String theme : themes) {
	    	Button btnTheme = new Button(container, SWT.CHECK);
	    	btnTheme.setText(theme);
		    
	    	if(IcygenThemesSupport.coreThemes.contains(theme)) {
	    		btnTheme.setEnabled(false);
		    	btnTheme.setSelection(true);
	    	}
	    	
		    setControl(btnTheme);
		    checkboxThemes.add(btnTheme);
	    }
	    
	    // Required to avoid an error in the system
	    setControl(container);
	    setPageComplete(true);
	}
	
	public ArrayList<Button> getCheckboxThemes()
	{
		return this.checkboxThemes;
	}
	
}
